#ifndef __COMMON_FUNC_H__
#define __COMMON_FUNC_H__

#include <Shlwapi.h>
#pragma comment(lib, "shlwapi.lib")
//#define CONFIG_FILE_NAME	_T("config.ini")
extern TCHAR g_szConfigFile[MAX_PATH];// = _T("config.ini");

__inline void GetCurrentPath(TCHAR * szPath, int nSize)
{
	::GetModuleFileName(NULL, szPath, nSize);
	::PathRemoveFileSpec(szPath);
}

__inline void GetConfigFilePath(CString & strPath)
{
	TCHAR szCurrentPath[MAX_PATH] = {0};
	GetCurrentPath(szCurrentPath, MAX_PATH);
	::PathCombine(szCurrentPath, szCurrentPath, g_szConfigFile);
	strPath = szCurrentPath;
}

#include <vector>
using namespace std;
__inline void CreateNestedDir(const CString & szFilePath, BOOL bIsFilePath = TRUE)
{
	TCHAR szLocalPath[MAX_PATH * 2] = {0};
	_tcsncpy(szLocalPath, szFilePath, MAX_PATH * 2);
	int nRemoveRet = 1;
	if (bIsFilePath)
	{
		nRemoveRet = ::PathRemoveFileSpec(szLocalPath);
	}

	vector<CString>m_vPath;
	while(nRemoveRet)
	{
		m_vPath.push_back(CString(szLocalPath));
		nRemoveRet = ::PathRemoveFileSpec(szLocalPath);
	}

	for (int i = m_vPath.size() - 1; i >= 0; --i)
	{
		if (::PathFileExists(m_vPath[i]))
		{
			continue;
		}
		::CreateDirectory(m_vPath[i], NULL);
	}
}



#endif